import { InMemoryDbService } from "angular-in-memory-web-api";

export class Hero{
    id:number;
    name:string;
}
export const HEROES:Hero[]=[
    { id: 11, name: 'Mr. Nice' },
    { id: 12, name: 'Narco' },
    { id: 13, name: 'Bombasto' },
    { id: 14, name: 'Celeritas' },
    { id: 15, name: 'Magneta' },
    { id: 16, name: 'RubberMan' },
    { id: 17, name: 'Dynama' },
    { id: 18, name: 'Dr IQ' },
    { id: 19, name: 'Magma' },
    { id: 20, name: 'Tornado' }
];
export class InMemoryDataService implements InMemoryDbService {
    createDb() {
      const heroes = [
        { id: 11, name: 'Mr. Nice Http' },
        { id: 12, name: 'Narco Http' },
        { id: 13, name: 'Bombasto Http' },
        { id: 14, name: 'Celeritas Http' },
        { id: 15, name: 'Magneta Http' },
        { id: 16, name: 'RubberMan Http' },
        { id: 17, name: 'Dynama Http' },
        { id: 18, name: 'Dr IQ Http' },
        { id: 19, name: 'Magma Http' },
        { id: 20, name: 'Tornado Http' }
      ];
      return {heroes};
    }
    genId(heroes: Hero[]): number {
        return heroes.length > 0 ? Math.max(...heroes.map(hero => hero.id)) + 1 : 11;
      }
}